<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>旧件发布系统-发布旧件</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="assets/layui/css/layui.css">
	<link rel="stylesheet" href="assets/css/all.css" />
	<style>
		.layui-table[lay-size=lg] td {
			padding: 10px;
		}
		.layui-textarea{
			min-height: 38px;
		}
		.layui-form-label{
			width:100px;
		}
		.musthave{
			color:red;
		}
	</style>
</head>
<body class="release-old">
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
		  <script src="assets/js/html5.min.js"></script>
		  <script src="assets/js/respond.min.js"></script>
		<![endif]-->
	<span class="layui-breadcrumb">
		<a>旧件发布系统</a>
		<a><cite>发布旧件</cite></a>
	</span>
	<div class="layui-container">
		<div class="layui-text">
			<h2 class="layui-field-title" style="text-align: center;">配件信息填写</h2>
			<!--<p class="warm-tip">注：带*为必填项</p>-->
		</div>
		<form class="layui-form" action="" onsubmit="return false;">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label layui-elip"><span class="musthave">*</span>车架号</label>
					<div class="layui-input-inline">
						<input type="text" name="cjnum" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label layui-elip"><span class="musthave">*</span>车型信息</label>
					<div class="layui-input-inline">
						<input type="text" name="cartype" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label"><span class="musthave">*</span>竞价结束日期</label>
					<div class="layui-input-inline">
						<input type="text" name="date4" id="date4" lay-verify="required" placeholder="年-月-日 时:分:秒" autocomplete="off" class="layui-input layui-date">
					</div>
				</div>	
				<div class="layui-inline">
					<label class="layui-form-label layui-elip"><span class="musthave">*</span>联系人 </label>
					<div class="layui-input-inline">
						<input type="text" name="contacter" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label layui-elip"><span class="musthave">*</span>联系电话</label>
					<div class="layui-input-inline">
						<input type="text" name="phone" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="car-location">
					<div class="layui-form-item">
						<label class="layui-form-label"><span class="musthave">*</span>车辆停放地</label>
						<div class="layui-input-inline">
							<select name="provid" id="provid" lay-filter="provid">
								<option value="">请选择省</option>
							</select>
						</div>
						<div class="layui-input-inline">
							<select name="cityid" id="cityid" lay-filter="cityid">
								<option value="">请选择市</option>
							</select>
						</div>
						<div class="layui-input-inline">
							<select name="areaid" id="areaid" lay-filter="areaid" onchange="getlocation()">
								<option value="">请选择县/区</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label"></label>
							<div class="layui-input-inline">
								<input id="detail-location" style="width:590px" type="text" name="detailid" placeholder="详细地址" autocomplete="off" class="layui-input" value="">
							</div>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label layui-elip">备注信息</label>
					<div class="layui-input-block" style="margin-left:100px;">
						<textarea class="layui-textarea" style="width:590px" name="" rows="" cols=""></textarea>
					</div>
				</div>
			</div>		
			<table id="old-table" class="layui-table">
				<thead>
					<tr>
						<th>配件名称</th>
						<th>原厂OEM号</th>
						<th>数量</th>
						<th>标准名称</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><input type="text" class="layui-input"/></td>
						<td><input type="text" class="layui-input"/></td>
						<td>
							<input type="text" class="layui-input"/>
						</td>
						<td>
						    <input type="text" class="layui-input"/>
						</td>
						<td>
							<a class="layui-btn layui-btn-danger layui-btn-xs del-btn">删除</a>
						</td>
					</tr>
					<tr>
						<td><input type="text" class="layui-input"/></td>
						<td><input type="text" class="layui-input"/></td>
						<td>
							<input type="text" class="layui-input"/>
						</td>
						<td>
						    <input type="text" class="layui-input"/>
						</td>
						<td>
							<a class="layui-btn layui-btn-danger layui-btn-xs del-btn">删除</a>
						</td>
					</tr>
				</tbody>
			</table>
			<button class="layui-btn layui-btn-primary add-old-line"><i class="layui-icon">&#xe608;</i> 新增一行</button>
			<div class="car-img">
				<div class="layui-upload imgupload layui-clear">
					<button type="button" class="layui-btn" id="old-up-btn"></button>
					<blockquote class="layui-elem-quote layui-quote-nm layui-clear" style="border:none"><span class="musthave">*</span>图片上传:(<span style="color: red;">点击图片可将其删除,文件类型jpg、png、bmp、jpeg,大小不超过2M</span>)
						<div class="layui-upload-list" id="pics-wrap">
							 <span class="add-bg">+</span>
						</div>
					</blockquote>
				</div>
			</div>
			<div style="text-align: center;margin:20px auto;">
				<button class="layui-btn" lay-submit lay-filter="submit-btn">发布询价</button>
			</div>
		</form>
	</div>
	
	<script src="assets/layui/layui.js"></script>
	<!--省市地区选择-->
	<script type="text/javascript" src="assets/js/data.js"></script>
	<script type="text/javascript" src="assets/js/province.js"></script>
	<script type="text/javascript">
		var defaults = {
			s1: 'provid',
			s2: 'cityid',
			s3: 'areaid',
			v1: null,
			v2: null,
			v3: null
		};
	</script>
	<!--//省市地区选择-->
	<script type="text/javascript" src="assets/js/all.js"></script>
	<script type="text/javascript">
		layui.use(['form','layer','upload'],function(){
			var form = layui.form,
				layer = layui.layer,
				upload = layui.upload,
				$ = layui.$
			//发布旧件系统js
			//新增一行
			$(".release-old").delegate(".add-old-line","click",function(){	
				var oldLine = '<tr><td><input type="text" class="layui-input"/></td><td><input type="text" class="layui-input"/></td><td><input type="text" class="layui-input"/</td><td><input type="text" class="layui-input"/></td><td><a class="layui-btn layui-btn-danger layui-btn-xs del-btn">删除</a></td></tr>';
				$(".release-old").find("#old-table tbody").append(oldLine);
			});
			//删除一行
			$("body").delegate(".del-btn","click",function(){
				var trs = $("#old-table tbody tr");
				if(trs.length > 1){
					var theBtn = $(this);
					layer.confirm("确定删除此行吗？",function(index){
						theBtn.parents("tr").remove();
						layer.close(index);
					});
				}else{
					//只剩一行不再删除
					layer.msg("至少要有一个配件")
				}
			});
			//图片上传
		    upload.render({
		    	elem: '#old-up-btn',
		    	url: '/upload/',
		    	multiple: true,
		    	size: 1024*2,
		    	number:0,
		    	before: function(obj) {
		    		//预读本地文件示例，不支持ie8
		    		obj.preview(function(index, file, result) {
		    			$('.release-old #pics-wrap').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img">')
		    		});
		    	},
		    	done: function(res) {
		    		//上传完毕
		    	}
		    });
		    //点击删除图片
		    $(".release-old").delegate(".imgupload blockquote img","click",function(){
		    	var theImg = $(this);
		    	layer.confirm("确定删除此张图片吗？",function(index){
		    		theImg.remove();
		    		layer.close(index);
		    	})
		    });	  
		    
		    
		    
		})
	</script>
</body>
</html>
